﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Registro.Compras.Data.Entities;

namespace Registro.Compras.Data.Business
{
    public class Tabla2Business
    {
        //CRUD + Logic business or constrains
        public static IList<Tabla2> GetListByFilter(string filter)
        {
            //throw new NotImplementedException();
            using (RegistroComprasDbContext ctx = new RegistroComprasDbContext()) // conexion a la db
            {
                return ctx.Tabla2s.Where(t => t.Descripcion.Contains(filter)).ToList(); 
            }
        }
        public static Tabla2 GetById(int id)
        {
            using (RegistroComprasDbContext ctx = new RegistroComprasDbContext())
            {
                Tabla2 Tabla2DB = ctx.Tabla2s.Find(id);
                if (Tabla2DB == null)
                {
                    throw new Exception("Tabla2 not found in data base");
                }
                return Tabla2DB;
            }
        }
    }
}
